<?php 
/* script performs cache warmup */
/* this script generates an xml sitemap for search engines */
require_once("config.php");

// application internal classes
require_once("class/cache.class.php");
require_once("class/database.class.php");
require_once("class/blog.class.php");
require_once("class/facebook.class.php");
require_once("class/search.class.php");
require_once("class/amazon.class.php");
require_once("class/analytics.class.php");

// instanciate the blog
$b = new blog($_SERVER["HTTP_HOST"]);

// instanciate the analytics
$a = new analytics();

// instance the amazon api
$amzn = new amazon($b->db->getLanguageCode());

// get all articles from the database
$articleList = $b->getLatestArticles(99999);

// go through all articles and request
// a cache refresh for the recommendations
for($i=0;$i<count($articleList);$i++){
		// load the recommendations
		// and force a cache refresh
		$a->getCachedRecommendations
			("/".$articleList[$i]["url"].".html",true);
			
		// load the amazon book recommendations
		// for the article and force cache refresh
		$amzn->itemSearchCached($articleList[$i]["keyword"], "Books");
}

// cache the top pages
$topArticleMonth = $a->getReportingMonth();
$a->getCachedThisMonthsTopArticles($topArticleMonth["number"],true);

// finally output a statement
echo ("Warm-Up process finished");
?>